package com.itheima.controller;


import com.itheima.domain.vo.Result;
import com.itheima.service.IFollowService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 坤哥
 * @since 2025-10-06
 */
@RestController
@RequestMapping("/follow")
@Slf4j
public class FollowController {
    @Resource
    private IFollowService followService;

    /**
     * 查询用户是否关注
     */
    @GetMapping("/or/not/{followedUserId}")
    public Result queryIsFollowed(@PathVariable("followedUserId") Long followedUserId){//博主的id
        log.info("当前博客的用户为：{}",followedUserId);
        return followService.queryIsFollowed(followedUserId);
    }

    /**
     * 用户关注功能
     */
    @PutMapping("/{followedUserId}/{isFollow}")
    public Result follow(@PathVariable("followedUserId") Long followedUserId,//博主的id
                         @PathVariable("isFollow") Boolean isFollow){
        log.info("当前被关注的用户为：{},是否被关注,{}",followedUserId,isFollow);
        return followService.follow(followedUserId,isFollow);
    }

    /**
     * 查询共同关注
     */
    @GetMapping("/common/{userId}")
    public Result queryCommonFollowed(@PathVariable("userId") Long blogUserId){//博主的id
        log.info("查询跟{}的共同关注",blogUserId);
        return followService.queryCommonFollowed(blogUserId);
    }
}
